<html>
    <title>This test verifies that the xml declaration gets serialized if present</title>
    <script src="../../resources/testharness.js"></script>
    <script src="../../resources/testharnessreport.js"></script>
    <script type="text/javascript">
        setup({single_test: true});

        var xmlpi = '<?xml version="1.0" encoding="UTF-8"?>';
        var markup = xmlpi + '<root><test/></root>';
        var xmldoc = new DOMParser().parseFromString(markup, "text/xml");
        assert_equals(new XMLSerializer().serializeToString(xmldoc).replace(/"/g,"'"), "<?xml version='1.0' encoding='UTF-8'?><root><test/></root>");

        xmlpi = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>';
        markup = xmlpi + '<root><test/></root>';
        xmldoc = new DOMParser().parseFromString(markup, "text/xml");
        assert_equals(new XMLSerializer().serializeToString(xmldoc).replace(/"/g,"'"), "<?xml version='1.0' encoding='UTF-8' standalone='yes'?><root><test/></root>");

        xmlpi = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>';
        markup = xmlpi + '<root><test/></root>';
        xmldoc = new DOMParser().parseFromString(markup, "text/xml");
        assert_equals(new XMLSerializer().serializeToString(xmldoc).replace(/"/g,"'"), "<?xml version='1.0' encoding='UTF-8' standalone='no'?><root><test/></root>");

        xmlpi = '<?xml version="1.0" standalone="yes"?>';
        markup = xmlpi + '<root><test/></root>';
        xmldoc = new DOMParser().parseFromString(markup, "text/xml");
        assert_equals(new XMLSerializer().serializeToString(xmldoc).replace(/"/g,"'"), "<?xml version='1.0' standalone='yes'?><root><test/></root>");

        xmlpi = '<?xml version="1.0" standalone="no"?>';
        markup = xmlpi + '<root><test/></root>';
        xmldoc = new DOMParser().parseFromString(markup, "text/xml");
        assert_equals(new XMLSerializer().serializeToString(xmldoc).replace(/"/g,"'"), "<?xml version='1.0' standalone='no'?><root><test/></root>");

        xmlpi = '<?xml version="1.0"?>';
        markup = xmlpi + '<root><test/></root>';
        xmldoc = new DOMParser().parseFromString(markup, "text/xml");
        assert_equals(new XMLSerializer().serializeToString(xmldoc).replace(/"/g,"'"), "<?xml version='1.0'?><root><test/></root>");
        done();

    </script>
</html>
